package com.friday.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.friday.bo.QueryAttendanceBo;
import com.friday.bo.impl.QueryAttendanceBoImpl;
import com.friday.po.SignInHistory;

public class QueryMyAttendanceServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		System.out.println("QueryMyAttendanceServlet");
		HttpSession session = request.getSession();
		QueryAttendanceBo queryAttendanceBo = new QueryAttendanceBoImpl();
		String id = (String)session.getAttribute("id");
		try {
			List<SignInHistory> histories = queryAttendanceBo.queryMyHistories(id);
			session.setAttribute("myattendance", histories);
			System.out.println("histories.size(): "+histories.size());
			response.sendRedirect("MyCheckDetails.jsp");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
